Dear Statalisters,
I am trying to use a global macro that contains a reference to a loop (`var').
This is the original code:
I want to create a global macro with the names of the models I want Stata to run:
Next, I use the $ command, where I substitute this text for $countries:
However, Stata seems not to identify the `var' before the country name, and the output is the following one:
Is there a way to use a global macro with loop content inside?
Thanks in advance,
Marc
I am trying to use a global macro that contains a reference to a loop (`var').
This is the original code:
Code:
levelsof country, local(levels) foreach l of local levels { foreach var of varlist y1 y2 y3 { eststo `var'_`l': reg `var' x1 if country== "`l'" } } foreach var of varlist y1 y2 y3 { local graphtitle : variable label `var' coefplot (`var'_Argentina \ `var'_Austria \ `var'_Belgium \ `var'_Brazil)
Code:
global countries "(`var'_Argentina \ `var'_Austria \ `var'_Belgium \ `var'_Brazil)"
Code:
levelsof country, local(levels) foreach l of local levels { foreach var of varlist y1 y2 y3 { eststo `var'_`l': reg `var' x1 if country== "`l'" } } foreach var of varlist y1 y2 y3 { local graphtitle : variable label `var' coefplot $countries
estimation result _Argentina not found
Thanks in advance,
Marc
Comment